import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { NameVO, NameForm, NameQuery,NameTreeVO,FamilyNameTreeVO } from '@/api/genealogy/name/types';

/**
 * 查询世代名称列表
 * @param query
 * @returns {*}
 */

export const listDraftName = (query?: NameQuery): AxiosPromise<NameVO[]> => {
  return request({
    url: '/genealogy/nameDraft/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询世代名称详细
 * @param id
 */
export const getDraftName = (id: string | number): AxiosPromise<NameVO> => {
  return request({
    url: '/genealogy/nameDraft/' + id,
    method: 'get'
  });
};

/**
 * 新增世代名称
 * @param data
 */
export const addDraftName = (data: NameForm) => {
  return request({
    url: '/genealogy/nameDraft',
    method: 'post',
    data: data
  });
};

/**
 * 修改世代名称
 * @param data
 */
export const updateDraftName = (data: NameForm) => {
  return request({
    url: '/genealogy/nameDraft',
    method: 'put',
    data: data
  });
};

/**
 * 删除世代名称
 * @param id
 */
export const delDraftName = (id: string | number | Array<string | number>) => {
  return request({
    url: '/genealogy/nameDraft/' + id,
    method: 'delete'
  });
};

/**
 * 查询族员数据结构
 */
export const getDraftNameTree = (data: NameForm): AxiosPromise<NameTreeVO[]> => {
  return request({
    url: '/genealogy/nameDraft/genealogyNameTree',
    method: 'post',
    data:data
  });
};

/**
 * 查询family tree族员数据结构
 */
export const getDraftFamilyTree = (): AxiosPromise<FamilyNameTreeVO[]> => {
  return request({
    url: '/genealogy/nameDraft/nameTreeList',
    method: 'get'
  });
};
